<!--
<template>
  &lt;!&ndash; 添加或修改项目基础信息管理对话框 &ndash;&gt;
  <el-dialog :title="title" :visible.sync="open" width="90%" append-to-body :close-on-click-modal="false" v-dialogDrag>
    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
      <el-tabs v-model="activeName" class="detail-tab" type="card">
        <el-tab-pane label="基本信息" name="first">
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="项目名称" prop="name">
                <el-input v-model="form.name" placeholder="请输入项目名称" disabled/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="项目负责人" prop="master">
                <el-input v-model="form.master" placeholder="请输入项目负责人" disabled/>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="客户" prop="customId">
                <el-select v-model="form.customId" placeholder="请选择客户" filterable
                           clearable disabled
                           style="width: 300px">
                  <el-option v-for="dict in dict.type.goods_customer" ref="myselectCustomerForPrj"
                             :key="dict.value" :label="dict.label" :value="dict.value"/>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="标识" prop="companyName">
                <el-select v-model="form.companyName" placeholder="请选择标识" filterable clearable disabled
                           style="width: 300px">
                  <el-option v-for="dict in dict.type.company"
                             :key="dict.value" :label="dict.label" :value="dict.value"/>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="合同金额" prop="contractMoney">
                <el-input-number :precision="2" v-model="form.contractMoney" placeholder="请输入合同金额" disabled
                />
                元
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="审计后金额" prop="auditMoney">
                <el-input-number :precision="2" v-model="form.auditMoney" placeholder="请输入审计后金额" disabled/>
                元
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="剩余回款" prop="remainMoney">
                <el-input-number :precision="2" v-model="form.remainMoney" placeholder="请输入剩余回款"
                                 disabled/>
                元
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="剩余开票金额" prop="taxRemain">
                <el-input-number :precision="2" v-model="form.taxRemain" disabled placeholder="请输入剩余开票金额"/>
                元
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="20">
            <el-col :span="6">
              <el-form-item label="费用金额" prop="feeMoney">
                <el-input-number :precision="2" v-model="form.feeMoney" placeholder="请输入费用金额"
                                 disabled/>
                元
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="销售金额" prop="saleMoney">
                <el-input-number :precision="2" v-model="form.saleMoney" placeholder="请输入销售金额"
                                 disabled/>
                元
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="销售成本" prop="buyMoney">
                <el-input-number :precision="2" v-model="form.buyMoney" placeholder="请输入销售成本"
                                 disabled/>
                元
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="利润" prop="profitMoney">
                <el-input-number :precision="2" v-model="form.profitMoney" placeholder="请输入利润"
                                 disabled/>
                元
                <el-button type="primary" @click="refreshProfit">重新计算</el-button>
              </el-form-item>
            </el-col>
          </el-row>

          &lt;!&ndash; <el-row :gutter="20">
             <el-col :span="8">
               <el-form-item label="是否验收" prop="checkState">
                 <el-select v-model="form.checkState" placeholder="是否验收" clearable style="width: 300px" disabled>
                   <el-option v-for="dict in dict.type.yes_no"
                              :key="dict.value" :label="dict.label" :value="dict.value"/>
                 </el-select>
               </el-form-item>
             </el-col>
             <el-col :span="8">
               <el-form-item label="验收日期" prop="checkDate">
                 <el-date-picker clearable disabled
                                 v-model="form.checkDate"
                                 type="date"
                                 value-format="yyyy-MM-dd"
                                 placeholder="请选择验收日期">
                 </el-date-picker>
               </el-form-item>
             </el-col>
             <el-col :span="8">
               <el-form-item label="是否回款完毕" prop="fundCallback">
                 <el-select v-model="form.fundCallback" placeholder="是否回款完毕" clearable style="width: 300px" disabled>
                   <el-option v-for="dict in dict.type.yes_no"
                              :key="dict.value" :label="dict.label" :value="dict.value"/>
                 </el-select>
               </el-form-item>
             </el-col>
           </el-row>
           <el-row :gutter="20">
             <el-col :span="8">
               <el-form-item label="合同签订日期" prop="contractDate">
                 <el-date-picker clearable disabled
                                 v-model="form.contractDate"
                                 type="date"
                                 value-format="yyyy-MM-dd"
                                 placeholder="请选择合同签订日期">
                 </el-date-picker>
               </el-form-item>
             </el-col>

             <el-col :span="24">
               <el-form-item label="备注信息" prop="infomation">
                 <el-input v-model="form.infomation" type="textarea" placeholder="请输入内容" disabled/>
               </el-form-item>
             </el-col>
           </el-row>&ndash;&gt;
        </el-tab-pane>
      </el-tabs>
    </el-form>

    <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleChose">选择费用</el-button>

    <el-table border v-loading="loading" ref="dragTable" :data="columns" row-key="id">
      <el-table-column label="序号" type="index" width="50" align="center">
        <template slot-scope="scope">
          <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
        </template>
      </el-table-column>
      <el-table-column label="商品名称" align="center" prop="goodsName"/>
      <el-table-column label="商品品牌" align="center" prop="brand"/>
      <el-table-column label="商品型号" align="center" prop="model"/>
      <el-table-column label="商品单位" align="center" prop="unit"/>
      <el-table-column label="含税单价" align="center" prop="costPriceTax"/>
      &lt;!&ndash;      <el-table-column label="采购数量" align="center" prop="count"/>&ndash;&gt;
      &lt;!&ndash;      <el-table-column label="库存数量" align="center" prop="remainderCount"/>&ndash;&gt;
      <el-table-column label="销售单价" align="center" prop="goodsUnitPrice"/>
      <el-table-column label="销售数量" align="center" prop="goodsCount"/>
      <el-table-column label="销售总价" align="center" prop="goodsTotalPrice"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-popconfirm :title="`确认删除 `+scope.row.goodsName+` 数据项？`" @confirm="handleDelete(scope.row)"
                         style="margin-left: 10px;">
            <el-button slot="reference" size="mini" type="text" icon="el-icon-delete"
                       v-hasPermi="['develop:ProjectBaseInfo:remove']">删除
            </el-button>
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>

    <div slot="footer" class="dialog-footer">
      &lt;!&ndash;      <el-button type="primary" @click="submitForm">确 定</el-button>&ndash;&gt;
      <el-button @click="cancel">取 消</el-button>
    </div>
    <goods-orderin-chose ref="formChose" @ok="refreshPageData"></goods-orderin-chose>
  </el-dialog>
</template>

<script>

    import {addAction, deleteAction, getAction, getById, updateAction} from '@/api/manage'
    import GoodsOrderinChose from "./GoodsOrderinChose";
    import {updateGoodsSale} from '@/api/develop/goodsProject'

    export default {
        name: "ProjectBaseInfoFormGoodsFee_bak",
        dicts: ['goods_customer', 'company', 'yes_no'],
        components: {
            GoodsOrderinChose
        },
        data() {
            return {
                // 遮罩层
                loading: true,
                activeName: "first",
                // 弹出层标题
                title: "",
                // 是否显示弹出层
                open: false,
                // 表单参数
                form: {},
                proId: "",
                columns: [],
                total: 0,
                // 表单校验
                rules: {
                    name: [
                        {required: true, message: "项目名称不能为空", trigger: "blur"}
                    ],
                    master: [
                        {required: true, message: "项目负责人不能为空", trigger: "blur"}
                    ],
                    customId: [
                        {required: true, message: "客户信息不能为空", trigger: "blur"}
                    ],
                },
                queryParams: {
                    pageNum: 1,
                    pageSize: 1000,
                    id: null,
                    name: null,
                    taxNo: null,
                    addr: null,
                    tel: null,
                    bankName: null,
                    bankNo: null,
                    info: null,
                    status: "0",
                    delFlag: null,
                    createBy: null,
                    createTime: null,
                    updateBy: null,
                    updateTime: null,
                    remark: null,
                    type: "3"
                },
                url: {
                    list: '/goodsSale/goodsSale/listSaleProject',
                    listBatch: '/goodsSale/goodsSale/listBatchSale/',
                    getById: '/projectBaseInfo/projectBaseInfo/',
                    add: '/projectBaseInfo/projectBaseInfo/add',
                    edit: '/projectBaseInfo/projectBaseInfo/edit',
                    remove: '/goodsSale/goodsSale/deleteProject/',
                },
            };
        },
        created() {

        },
        methods: {
            //重新计算利润,因部分旧数据未参与计算 : 商品销售金额为新增加字段
            refreshProfit() {
                let that = this;
                let params = {id: this.proId};
                getAction("/projectBaseInfo/projectBaseInfo/refreshProfit", params).then(response => {
                    that.refreshPageData();
                });
            },
            refreshPageData() {
                let that = this;
                let param = {
                    id: that.proId
                }
                that.handleUpdate(param);

            },
            /*handleChangeMoney(row) {
                let that = this;
                let handleReckonMoney = (row) => {
                    let row_money = 0;
                    row_money = that.functionNumberMul(Number(row.goodsUnitPrice), Number(row.goodsCount))
                    that.$set(row, 'goodsTotalPrice', row_money);
                };
                handleReckonMoney(row);
            },*/
            /*functionNumberMul(arg1, arg2) {
                var m = 0;
                var s1 = arg1.toString();
                var s2 = arg2.toString();
                try {
                    m += s1.split(".")[1].length;
                } catch (e) {
                }
                try {
                    m += s2.split(".")[1].length;
                } catch (e) {
                }
                return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m);
            },*/
            handleChose() {
                this.$refs.formChose.chose(this.proId, "3");
            },
            getList() {
                this.loading = true;
                /*getById(this.url.listBatch, this.ids).then(response => {
                  this.columns = response.rows;
                  this.total = response.total;
                  this.loading = false;
                });*/
                this.queryParams.projectId = this.proId
                getAction(this.url.list, this.queryParams).then(response => {
                    this.columns = response.rows;
                    this.total = response.total;
                    this.loading = false;
                });
            },
            handleDelete(row) {
                const ids = row.id || this.ids;
                deleteAction(this.url.remove, ids).then(response => {
                    this.refreshPageData();
                    this.$modal.msgSuccess("删除成功");
                }).catch(() => {
                });
            },
            /*handleUpdateDetail(row) {
                this.reset();
                const id = row.id || this.ids;
                getById(this.url.getById, id).then(response => {
                    this.form = response.data;
                    this.open = true;
                    this.title = "完善项目信息";
                });
            },*/
            /*updateAuditMoney(value) {
                this.$set(this.form, "auditMoney", value);
            },*/
            /*selectCustomerForPrj(value) {
                let that = this;
                that.$nextTick(() => {
                    let arr = that.$refs.myselectCustomerForPrj;
                    for (let i = 0; i < arr.length; i++) {
                        if (arr[i].currentValue == value) {
                            that.form.customName = arr[i].label;
                        }
                    }
                })
            },*/
            // 取消按钮
            cancel() {
                this.open = false;
                this.reset();
            },
            // 表单重置
            reset() {
                this.form = {
                    id: null,
                    delFlag: null,
                    createBy: null,
                    createTime: null,
                    updateBy: null,
                    updateTime: null,
                    remark: null,
                    name: null,
                    master: null,
                    customId: null,
                    customName: null,
                    companyName: null,
                    contractDate: null,
                    contractMoney: null,
                    auditMoney: null,
                    checkDate: null,
                    checkState: null,
                    retentionMoney: null,
                    retentionDate: null,
                    fundCallback: null,
                    infomation: null
                };
                this.resetForm("form");
            },
            /** 新增按钮操作 */
            /*handleAdd() {
                this.reset();
                this.open = true;
                this.title = "添加项目基础信息管理";
            },*/
            /** 修改按钮操作 */
            handleUpdate(row) {
                this.reset();
                const id = row.id || this.ids;
                this.proId = id;
                getById(this.url.getById, id).then(response => {
                    this.form = response.data;
                    this.open = true;
                    this.title = "修改项目基础信息管理";
                    this.getList();
                });
            },
            /** 提交按钮 */
            /*submitForm() {
                let that = this;
                that.$refs["form"].validate(valid => {
                    if (valid) {
                        /!*const goodsSaleForm = that.form;
                        const goodsOrderIn = Object.assign({}, goodsSaleForm);
                        goodsOrderIn.columns = that.columns;
                        goodsOrderIn.form = goodsSaleForm;
                        updateGoodsSale(goodsOrderIn).then(res => {
                          that.$modal.msgSuccess(res.msg);
                          if (res.code === 200) {
                            that.$modal.msgSuccess("修改完成！");
                            that.open = false;
                            that.$emit('ok');
                          }
                        });*!/
                        if (this.form.id != null) {
                            updateAction(this.url.edit, this.form).then(response => {
                                this.$modal.msgSuccess("修改成功");
                                this.open = false;
                                this.$emit('ok');
                            });
                        } else {
                            addAction(this.url.add, this.form).then(response => {
                                this.$modal.msgSuccess("新增成功");
                                this.open = false;
                                this.$emit('ok');
                            });
                        }
                    }
                });
            },*/
        }
    };
</script>
-->
